package net.oxygen.upload.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import net.oxygen.upload.enums.BizCodeEnum;

/**
 * <p>
 * 功能：自定义业务异常
 * </p>
 *
 * @author 陈伟伟
 * @since 2023/12/13 10:45
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException{

    private Integer code;

    private String message;

    public BizException(String message, Integer code) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.message = bizCodeEnum.getMessage();
    }

    public BizException(BizCodeEnum bizCodeEnum, String message) {
        super(message);
        this.code = bizCodeEnum.getCode();
        this.message = message;
    }
}
